﻿
#Region "Using Directives"

Imports System

#End Region

Namespace C4F.DevKit.Bluetooth.ObjectPushProfile

#Region "BusinessCardExchangeCompletedEventArgs"

    ''' <summary>
    ''' EventArgs class to be used when a Business Card Exchange operation
    ''' completes.
    ''' </summary>
    Public Class BusinessCardExchangeCompletedEventArgs
        Inherits ComponentModel.AsyncCompletedEventArgs

#Region "Private Fields"

        ''' <summary>
        ''' The name of the card that was pushed.
        ''' </summary>
        Private m_localCardName As String

        ''' <summary>
        ''' The name of the card that was pulled.
        ''' </summary>
        Private remoteCardName As String

        ''' <summary>
        ''' The card that was pulled.
        ''' </summary>
        Private m_remoteCardContents() As Byte

#End Region

#Region "Public Properties"

        ''' <summary>
        ''' Gets the name of the card that was pushed to the remote device.
        ''' </summary>
        Public ReadOnly Property LocalCardName() As String

            Get
                Return Me.m_localCardName
            End Get

        End Property

        ''' <summary>
        ''' Gets the name of the card that was pulled from the remote device.
        ''' </summary>
        Public ReadOnly Property OutputCardName() As String

            Get
                RaiseExceptionIfNecessary()
                Return Me.remoteCardName
            End Get

        End Property

        ''' <summary>
        ''' Gets the contents of the business card that was pulled from the
        ''' remote device.
        ''' </summary>
        Public ReadOnly Property RemoteCardContents() As Byte()

            Get
                RaiseExceptionIfNecessary()
                Return Me.m_remoteCardContents
            End Get

        End Property

#End Region

#Region "Constructors"

        ''' <summary>
        ''' Initializes the BusinessCardExchangeCompletedEventArgs object.
        ''' </summary>
        ''' <param name="localCardName">The name of the card that was pushed to
        ''' the remote device.</param>
        ''' <param name="remoteCardName">The name of the card that was pulled
        ''' from the remote device.</param>
        ''' <param name="remoteCardContents">The byte stream of the card that 
        ''' was pulled from the remote device.</param>
        ''' <param name="error">An error that occurred during the asynchronous
        ''' operation.</param>
        ''' <param name="cancelled">A value indicating whether the asynchronous
        ''' operation was cancelled.</param>
        ''' <param name="userState">The user-supplied state object supplied 
        ''' when the asynchronous operation was requested.</param>
        ''' <exception cref="ArgumentNullException">localCardName or 
        ''' remoteCardName is passed as an empty string or a null reference or
        ''' remoteCardContents is passed as a null reference.</exception>
        Public Sub New(ByVal localCardName As String, ByVal remoteCardName As String, ByVal remoteCardContents() As Byte, _
                        ByVal [error] As Exception, ByVal cancelled As Boolean, ByVal userState As Object)

            MyBase.New([error], cancelled, userState)

            If String.IsNullOrEmpty(localCardName) Then
                Throw New ArgumentNullException("localCardName")
            End If

            If remoteCardName Is Nothing Then
                Throw New ArgumentNullException("remoteCardName")
            End If

            If remoteCardContents Is Nothing Then
                Throw New ArgumentNullException("remoteCardContents")
            End If

            With Me

                .m_localCardName = localCardName
                .remoteCardName = remoteCardName
                .m_remoteCardContents = remoteCardContents

            End With

        End Sub

#End Region

    End Class

#End Region

End Namespace